

/*
 点评控制器
 1.0 keybo 2016/07/19
*/
appController.controller("reviewCtrl",["$scope","isNaN",function($scope,isNaN){
      $scope.updateData={};
     
     $scope.insertname="";
     $scope.updateData.score="";
     $scope.first=function(){

      //请求点评数据
     util.get("getAllInformationQuality.do",null,function(response){

        $scope.$apply(function () {
     　　  $scope.data = response.object;
        });
     },function(){
     })


   };

   $scope.second=function(){

          //修改数据 点击保存后，将数据传值后台
      util.get("modifyQuality.do",$scope.updateData,function(response){
          $scope.first();
        },function(){
        })
  
   return false;
     

   }
   
    $scope.first();
   
   jq("input[type='text']").attr('disabled','disabled');
    
   //修改
   $scope.update=function(index,index1){
     
      if(jq("#"+index).html()=="修改")
      {
         jq("#"+index).html("保存");
         jq("input[type='text']:eq("+index1+")").removeAttr('disabled');
         jq("input[type='text']:eq("+index1+")").addClass("date-ok");
      }
      else
      {
        jq("input[type='text']:eq("+index1+")").removeClass("date-ok");
        jq("#"+index).html("修改");
        jq("input[type='text']").attr('disabled','disabled');     
        var name=jq("#"+index).parent().prev().prev().html();
        $scope.updateData.id=index;
        $scope.updateData.name=name;   
        $scope.updateData.score=jq("#"+index).parent().prev().find("input").eq(0).val();
   
        $scope.hex =isNaN.myFunc( $scope.updateData.score);
        if($scope.hex)
            $scope.second();
        else
        {jq("#badmodal").modal('show');
      $scope.first();
        }
      }

      
     
     
   }
   //删除，把id传值给后台
    $scope.delted=function(index){
       jq("#delemodal").modal('hide');
      util.get("delQuality.do",$scope.id,function(re){
        if(re.status)
        {
             $scope.first();
        }
        else
        {
            jq("#badmodal").modal('show');
        }
    },function(){
       jq("#badmodal").modal('show');
    })
  };
  $scope.submit=function(index){
      $scope.id="id="+index;
      jq("#delemodal").modal('show');
    }
  //模态框
    $scope.submitInfo=function(){

      jq("#addModel").find("input").removeAttr("disabled");
      jq("#addModel").modal('show');
    }

   //新建等级确认保存，将值传到后台
   $scope.saveInfo=function(){
    $scope.info={};
    $scope.info.name=$scope.insertname;
    if($scope.insertname!="" )
    {
      $scope.info.score=$scope.insertscore;
      $scope.hex =isNaN.myFunc( $scope.info.score);
      if($scope.hex)
      {
      util.get("addQuality.do",$scope.info,function(){
        jq("#addModel").modal('hide');
        $scope.first();

        },function(){
       })

      }
    else
    {
      jq("#badmodal").modal('show');
    }


    }
    else
    {
       jq("#badmodal").modal('show');
    }
    

   }


}])


/*
 质量控制器
 1.0 keybo 2016/07/19
*/
appController.controller("qualityCtrl",["$scope","isNaN",function($scope,isNaN){
      $scope.updateData={};
     $scope.insertname="";
     $scope.updateData.score="";
     $scope.first=function(){
      //请求点评数据
     util.get("getAllTasCompletion.do",null,function(response){
        $scope.$apply(function () {
     　　  $scope.data = response.object;
        });
       
     },function(){
       
     })


   };

   $scope.second=function(){

          //修改数据 点击保存后，将数据传值后台
      util.get("modifyCompletion.do",$scope.updateData,function(response){
        
          $scope.first();
        },function(){
        
        })
  
   return false;
     

   }
   
    $scope.first();
   
   jq("input[type='text']").attr('disabled','disabled');
    
   //修改
   $scope.update=function(index,index1){
     
      if(jq("#"+index).html()=="修改")
      {
         jq("#"+index).html("保存");
         jq("input[type='text']:eq("+index1+")").removeAttr('disabled');
         jq("input[type='text']:eq("+index1+")").addClass("date-ok");
      }
      else
      {
        jq("input[type='text']:eq("+index1+")").removeClass("date-ok");
        jq("#"+index).html("修改");
        jq("input[type='text']").attr('disabled','disabled');     
        var name=jq("#"+index).parent().prev().prev().html();
        $scope.updateData.id=index;
        $scope.updateData.name=name;   
        $scope.updateData.score=jq("#"+index).parent().prev().find("input").eq(0).val();
 
        $scope.hex =isNaN.myFunc( $scope.updateData.score);
        if($scope.hex)
            $scope.second();
        else
        {jq("#badmodal").modal('show');
      $scope.first();
        }
      }

      
     
     
   }




  $scope.submit=function(index){

      $scope.id="id="+index;
      jq("#delemodal").modal('show');
    }
  //模态框
    $scope.submitInfo=function(){

      jq("#addModel").find("input").removeAttr("disabled");
      jq("#addModel").modal('show');
    }

   //删除，把id传值给后台
    $scope.delete=function(){
       jq("#delemodal").modal('hide');
      util.get("delCompletion.do",$scope.id,function(re){
        if(re.status)
        {
             $scope.first();
       
        }
        else
        {
            jq("#badmodal").modal('show');
        }
       
      
    },function(){
       jq("#badmodal").modal('show');
    })
  };
   //新建等级确认保存，将值传到后台
   $scope.saveInfo=function(){
    $scope.info={};
    $scope.info.name=$scope.insertname;
 
    if($scope.insertname!="" )
    {
      $scope.info.score=$scope.insertscore;
      $scope.hex =isNaN.myFunc( $scope.info.score);
      if($scope.hex)
      {
      util.get("addCompletion.do",$scope.info,function(){
        jq("#addModel").modal('hide');
        $scope.first();

        },function(){
       })

      }
    else
    {
      jq("#badmodal").modal('show');
    }


    }
    else
    {
       jq("#badmodal").modal('show');
    }
    

   }


}])

/*
 评价控制器
 1.0 keybo 2016/07/19
*/
appController.controller("comreviewCtrl",["$scope","isNaN",function($scope,isNaN){
     $scope.updateData={};
     $scope.insertname="";
     $scope.updateData.score="x";
    $scope.first=function(){
      //请求点评数据
     util.get("getAllTasCompletion.do",null,function(response){
        $scope.data=response.object;
   
     },function(){
      
     })


   };

   $scope.second=function(){

          //修改数据 点击保存后，将数据传值后台
      util.get("modifyCompletion.do",$scope.updateData,function(response){
       
          $scope.first();
        },function(){
        
        })
  
   return false;
     

   }
   
    $scope.first();

   jq("input[type='text']").attr('disabled','disabled');
    
   //修改
   $scope.update=function(index,index1){
     
      if(jq("#"+index).html()=="修改")
      {
         jq("#"+index).html("保存");
         jq("input[type='text']:eq("+index1+")").removeAttr('disabled');
         jq("input[type='text']:eq("+index1+")").addClass("date-ok");
      }
      else
      {
        jq("input[type='text']:eq("+index1+")").removeClass("date-ok");
        jq("#"+index).html("修改");
        jq("input[type='text']").attr('disabled','disabled');     
       var name=jq("#"+index).parent().prev().prev().html();
        $scope.updateData.id=index;
        $scope.updateData.name=name;   
        $scope.updateData.score=jq("#"+index).parent().prev().find("input").eq(0).val();
     
         $scope.hex =isNaN.myFunc( $scope.updateData.score);
        if($scope.hex)
            $scope.second();
        else
        {jq("#badmodal").modal('show');
          $scope.first();
        }
      }

      
     
     
   }

 //删除，把id传值给后台
    $scope.delted=function(index){
       jq("#delemodal").modal('hide');
      util.get("delCompletion.do",$scope.id,function(re){
        if(re.status)
        {
             $scope.first();
            
        }
        else
        {
            jq("#badmodal").modal('show');
        }
       
      
    },function(){
       
    })
  };

  //模态框
    $scope.submitInfo=function(){
      jq("#addModel").find("input").removeAttr("disabled");
      jq("#addModel").modal('show');
    }
      $scope.submit=function(index){
      $scope.id="id="+index;
      jq("#delemodal").modal('show');
    }

   //新建等级确认保存，将值传到后台
 
    $scope.saveInfo=function(){
    $scope.info={};
    $scope.info.name=$scope.insertname;
    $scope.info.score=$scope.insertscore;
    if($scope.info.name!="")
    {
    	
      
    	$scope.hex =isNaN.myFunc( $scope.info.score);
    	if($scope.hex)
	      {
	   
	        util.get("addCompletion.do",$scope.info,function(){
	      
	        	jq("#addModel").modal('hide');
	        	$scope.first();
	
	        	},function(){
	        		
	        	})
	
	      }else{
	    	  jq("#badmodal").modal('show');
	      }


    }else{
       jq("#badmodal").modal('show');
    }
    
}



}]);

/*
 监狱结构-添加结构控制器
 1.0 keybo 2016/07/19
*/
appController.controller("addDepartmentCtrl",["$scope","$http",function($scope,$http){
   //向服务器请求上层结构
	 $scope.firstStruct1=1;
	
  util.get("getAllSuperStructure.do",null,
  function(response){
	  $scope.$apply(function(){
           $scope.firstStruct=response.object;
         })
  },function(re){
     
  });
  $scope.info={};

  //建立按钮
  $scope.build=function(){
     //jq("#myModal").modal('show');
     $scope.info.superId=$scope.firstStruct1;
     $scope.info.name=$scope.structureName;
     $scope.info.remark=$scope.remark;
     $scope.typeName=jq(".type :selected").val();
     if(($scope.typeName)==0){
    	 $scope.info.typeName="科室";
    	 $scope.info.value="Department";
    	 $scope.info.num="1";
     }else if(($scope.typeName)==1) {
    	 $scope.info.typeName="监区分口";
    	 $scope.info.value="Mouth";
    	 $scope.info.num="1";
     }else{
    	 $scope.info.typeName="分监区";
    	 $scope.info.value="ChildPrisonArea";
    	 $scope.info.num="2";
     }
   
     //向服务器传输info数据
     if($scope.info.name!="")
     {
       util.post("addPrisonStructure.do", $scope.info
            ,function(re){
              if(re.status)
              {
                jq("#goodmodel").modal('show');
                $scope.firstStruct1="";
                $scope.structureName="";
                $scope.remark="";
              
              }
              else
              {
                jq("#badmodal").modal('show');
              }
            },
            function(){
              jq("#badmodal").modal('show');
                
            });

     }
     else
     {
        jq("#badmodal").modal('show');
     }
     
  }




}])
/*
 监狱结构-添加监狱监区控制器
 1.0 mouse 2016/08/12
*/
appController.controller("addPrisonCtrl",["$scope","$http",function($scope,$http){
  //建立按钮
  $scope.info={};
  $scope.build=function(){
     //jq("#myModal").modal('show');
     $scope.info.name=$scope.structureName;
     $scope.info.remark=$scope.remark;
     $scope.typeName=jq(".type :selected").val();
    
     if(($scope.typeName)==0){
    	 $scope.info.typeName="科室";
    	 $scope.info.value="Department";
    	 $scope.info.num="1";
    	 $scope.info.superId=1;
     }else  {
    	 $scope.info.typeName="监区";
    	 $scope.info.value="PrisonArea";
    	 $scope.info.num="0";
     }
     /*alert();*/
     //向服务器传输info数据
     if($scope.info.name!="")
     {
       util.post("addSuperStructure.do", $scope.info
            ,function(re){
              if(re.status)
              {
                jq("#goodmodel").modal('show');
                $scope.structureName="";
                $scope.remark="";  
              }
              else
              {
                jq("#badmodal").modal('show');
              }
            },
            function(){
              jq("#badmodal").modal('show');

            });
     }
     else
     {
        jq("#badmodal").modal('show');
     }     
  }
}]);
/*
监狱结构-临时修改控制器
1.0 keybo 2016/07/21
*/
appController.controller("modifyEnsembleCtrl",["$scope","$http",function($scope,$http){
	util.get("getQuestionStructure.do","null",function(response){
		if(response.status){
			var object=response.object;
			for(var i=0;i<object.length;i++){
				
				var html="<option  value="+object[i].id+" >"+object[i].name+"</option>";
				jq(".questionStructure").append(html);
			}
		}
			  
	},function(){

	});
	 $scope.info={};
	 $scope.modifyStructure=function(){
		 $scope.info.id=jq(".questionStructure :selected").val();
	     $scope.typeName=jq(".type :selected").val();
	     if(($scope.typeName)==0){
	    	 $scope.info.typeName="科室";
	    	 $scope.info.value="Department";
	    	 $scope.info.num="1";
	    	 $scope.info.superId=1;
	     }else if(($scope.typeName)==1) {
	    	 $scope.info.typeName="监区";
	    	 $scope.info.value="PrisonArea";
	    	 $scope.info.num="0";
	     }else {
	    	 $scope.info.typeName="分监区";
	    	 $scope.info.value="ChildPrisonArea";
	    	 $scope.info.num="2";
	     }
	     /*alert();*/
	     //向服务器传输info数据
	     
	     
	       util.post("modifyQuestionStructure.do", $scope.info,function(re){
	              if(re.status)
	              {
	            	  jq("#goodmodel").modal('show');
	               
	              }else{
	                
	              }
	            },
	            function(){
	              jq("#badmodal").modal('show');

	            });
	     }
	      
	  
	 

}])




/*
 监狱结构-修改控制器
 1.0 keybo 2016/07/21
*/
appController.controller("updateEnsembleCtrl",["$scope","$http",function($scope,$http){
  $scope.deleteid=0;
  $scope.deleindex=0;
  $scope.submitInfo=function(deleteid,index){
      $scope.deleteid=deleteid;
      $scope.deleindex=index;
      jq("#myModal").modal('show');

  }
   //模态框确认删除按钮
  $scope.delete=function(){
    var id="id="+$scope.deleteid;
  util.get("deleteStructureById.do",id
  ,function(re){
      if(re.status==false)
      {
        jq("#badmodal").modal('show');
      }
      else
      {
         jq("#"+$scope.deleindex).parent().remove();
      }
       

  }
  ,function(){


      

  });
  jq("#myModal").modal('hide');

  }

  
 
  $scope.data={};
  //向服务器传输筛选数据
  $scope.x=1;
  $scope.select=function(superId){
    $scope.superId=superId;
    var s="superId="+superId;
    util.get("getAllStructureBySuperId.do",s,
      function(response){
        
        
          $scope.$apply(function(){
           $scope.data=response.object;
         })

        
       

      },
      function(){
       jq("#badmodal").modal('show');
      }
      );

  }

  //向服务器请求上层结构
  util.get("getAllSuperStructure.do",null
  ,function(response){

     $scope.firstStruct=response.object;
     
     var s="superId="+1;
     util.get("getAllStructureBySuperId.do",s,function(res){
    	$scope.$apply(function(){
        $scope.data=res.object;
      })
    	 
     },function(){
    	       
     });
  },
  function(){

  });

  $scope.update=function(index,id,superId){
   if(jq("tr").eq(index+1).find("a").html()=="修改")
   {
      jq("tr").eq(index+1).find("input").addClass("date-ok").removeAttr("disabled");
      jq("tr").eq(index+1).find("a").html("保存");
   }
   else
   {
   

    $scope.updateDate={};
    $scope.updateDate.name="";
    $scope.updateDate.id=id;
    $scope.updateDate.name=jq("tr").eq(index+1).find("input").eq(0).val();
     $scope.updateDate.superId=superId;
    $scope.updateDate.remark=jq("tr").eq(index+1).find("input").eq(1).val();

    if($scope.updateDate.name!="")
    {
         util.post("modifyPrisonStructure.do",$scope.updateDate
            ,function(re){
              if(re.status)
              {
              }
              else
              {
                jq("#badmodal").modal('show');
              }
              
            }
            ,function(){
              jq("#badmodal").modal('show');
            });


    }
    else
    {
      jq("#badmodal").modal('show');
      $scope.select($scope.superId);
    }
   



      jq("tr").eq(index+1).find("input").removeClass("date-ok").attr("disabled","disabled");
      jq("tr").eq(index+1).find("a").html("修改");
   }
   
  }

}])

/*
 权限控制器
 1.0 keybo 2016/07/21
*/
appController.controller("powerCtrl",["$scope",function($scope){
  $scope.data=[
  {id:1,name:"信息添加"},
  {id:2,name:"信息管理"},
  {id:3,name:"初审"},
  {id:4,name:"复核"},
  {id:5,name:"审核"},
  {id:6,name:"信息研判"},
  {id:7,name:"任务派遣"},
  {id:8,name:"即时任务派遣"},
  {id:9,name:"任务完成情况"},
  {id:10,name:"信息操作"},
  {id:11,name:"点评"},
  {id:12,name:"评价"}]
 
   

  $scope.submitInfo=function(){
      jq("#myModal").modal('show');
  }


}])

/*
 权限修改控制器
 1.0 keybo 2016/07/22
*/
appController.controller("updatePowerCtrl",["$scope","$http","$routeParams",function($scope,$http,$routeParams){
 
  //获取权限页传来的模块权限名称
  $scope.powername="name="+$routeParams.powername;

  //在后台获取模块的权限
  util.get("getPowerModuleByName.do",$scope.powername,function(response){
    $scope.data=response.object;
    $scope.id=$scope.data.id;
       $('input[name=source]').get($scope.data.informatioSource).checked = true;
       $('input[name=port]').get($scope.data.safetyPort).checked = true;
       $('input[name=person]').get($scope.data.inputPerson).checked = true;
       $('input[name=profile]').get($scope.data.idinformationProfile).checked = true;
       $('input[name=content]').get($scope.data.informationContent).checked = true;
       $('input[name=measure]').get($scope.data.measure).checked = true;
       $('input[name=standard]').get($scope.data.standard).checked = true;
       $('input[name=ification]').get($scope.data.informationClassification).checked = true;
       $('input[name=sort]').get($scope.data.informationSort).checked = true;
       $('input[name=appendix]').get($scope.data.appendix).checked = true;
       $('input[name=completion]').get($scope.data.taskCompletion).checked = true;
       $('input[name=review]').get($scope.data.review).checked = true;
       $('input[name=appraise]').get($scope.data.appraise).checked = true;
       if($scope.data.informationAllocation)
       {
          $('input[name=allocation]').get(0).checked = true;
       }
       else
       {
          $('input[name=allocation]').get(1).checked = true;
       }
       if($scope.data.informationRetrieve)
       {
           $('input[name=retrieve]').get(0).checked = true;
       }
       else
       {
          $('input[name=retrieve]').get(1).checked = true;
       }

        if($scope.data.informationMerge)
       {
          $('input[name=merge]').get(0).checked = true;
       }
       else
       {
          $('input[name=merge]').get(1).checked = true;
       }


       if($scope.data.taskDispatch)
       {
          $('input[name=dispatch]').get(0).checked = true;
        }
       else
       {
          $('input[name=dispatch]').get(1).checked = true;
       }
        if($scope.data.informationExport)
       {
           $('input[name=export]').get(0).checked = true;
       }
       else
       {
          $('input[name=export]').get(1).checked = true;
       }
      
     

       
 
  },function(){

  })
 //$("input[name="+data.id+"]:eq(0)").attr("checked",'checked'); 
  $scope.submitInfo=function(){
      jq("#myModal").modal('show');
  }
  //模态框-确认按钮
 $scope.savePower=function(){
    jq("#myModal").modal('hide');
    $scope.info={};
    $scope.info.id=$scope.id;
    $scope.info.name=$routeParams.powername;
    $scope.info.informatioSource= $('input[name=source]:checked').val();
    $scope.info.safetyPort=$('input[name=port]:checked').val();
    $scope.info.inputPerson=$('input[name=person]:checked').val();
    $scope.info.idinformationProfile=$('input[name=profile]:checked').val();
    $scope.info.informationContent=$('input[name=content]:checked').val();
    $scope.info.measure=$('input[name=measure]:checked').val();
    $scope.info.standard=$('input[name=standard]:checked').val();
    $scope.info.informationClassification=$('input[name=ification]:checked').val();
    $scope.info.informationSort=$('input[name=sort]:checked').val();
    $scope.info.appendix=$('input[name=appendix]:checked').val();
    $scope.info.taskCompletion=$('input[name=completion]:checked').val();
    $scope.info.review=$('input[name=review]:checked').val();
    $scope.info.appraise=$('input[name=appraise]:checked').val();

    $scope.info.informationAllocation=$('input[name=allocation]:checked').val();
    $scope.info.informationRetrieve=$('input[name=retrieve]:checked').val();
    $scope.info.informationMerge=$('input[name=merge]:checked').val();
    $scope.info.taskDispatch=$('input[name=dispatch]:checked').val();
    $scope.info.informationExport=$('input[name=export]:checked').val();
    var curData=$scope.info;
    util.get("modifyPowerModule.do",curData,function(re){
     
    },function(){

    });
  }

}]);


/*
 权限修改控制器
 1.0 keybo 2016/07/22
*/
appController.controller("yanzmCtrl",["$scope",function($scope){
/* alert();*/

}]);
